package com.niuquan.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.niuquan.activitie.R;
import com.niuquan.modal.ResultList;
import com.niuquan.uicomponent.CircularImage;
import com.niuquan.uicomponent.starlist;

import java.util.ArrayList;

/**
 * Created by DELL on 2015/5/24.
 */
public class XunniuResultAdapter  extends BaseAdapter {
    public ArrayList<ResultList> m_items;
    private LayoutInflater inflater=null;
    private Context context;
    public XunniuResultAdapter() {
    }
    public XunniuResultAdapter(Context context,ArrayList<ResultList> items)
    {
        this.context = context;
        m_items = items;
        inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if(convertView == null){
            convertView = inflater.inflate(R.layout.layout_jieguo_item, null);
        }
        CircularImage headpic = (CircularImage) convertView.findViewById(R.id.resultheadpic);
        TextView username = (TextView) convertView.findViewById(R.id.resultnickname);
        starlist m_starlist =(starlist)convertView.findViewById(R.id.resultstar);

        username.setText(m_items.get(position).getNickname());
        headpic.setImageBitmap(m_items.get(position).getBitmapDrawable());
        m_starlist.setstar_num(m_items.get(position).getRank());
        return convertView;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public ResultList getItem(int position) {
        return m_items.get(position);
    }

    @Override
    public int getCount() {
        return m_items.size();
    }
}